package com.dzu.easy;

/**
 * @author ZhaoDong
 * @date 2022/11/9 18:05
 * @description leetcode
 */
public class Test504 {
    public static void main(String[] args) {
        System.out.println(convertToBase7(100));
    }
    public static String convertToBase7(int num) {
        if (num == 0) {
            return "0";
        }
        boolean negative = num < 0;
        num = Math.abs(num);
        StringBuffer digits = new StringBuffer();
        while (num > 0) {
            digits.append(num % 7);
            num /= 7;
        }
        if (negative) {
            digits.append('-');
        }
        return digits.reverse().toString();
    }


}
